<template>
	<view class="page">
		<view class="flex-box align-center item">
			<input v-if='seeoldpwd' type="text" v-model="oldpwd" placeholder="请输入旧密码" class="flex" placeholder-class="pla"/>
			<input v-else type="password" v-model="oldpwd" placeholder="请输入旧密码" class="flex" placeholder-class="pla"/>
			<text class="iconfont" :class="seeoldpwd?'icon-yanjing':'icon-yanjing1'" @click="seeoldpwd = !seeoldpwd"></text>
		</view>
		<view class="flex-box align-center item">
			<input v-if='seenewpwd' type="text" v-model="newpwd" placeholder="请输入新密码" class="flex" placeholder-class="pla"/>
			<input v-else type="password" v-model="newpwd" placeholder="请输入新密码" class="flex" placeholder-class="pla"/>
			<text class="iconfont" :class="seenewpwd?'icon-yanjing':'icon-yanjing1'" @click="seenewpwd = !seenewpwd"></text>
		</view>
		<view class="flex-box align-center item">
			<input v-if='seerepwd' type="text" v-model="repwd" placeholder="请确认新密码" class="flex" placeholder-class="pla"/>
			<input v-else type="password" v-model="repwd" placeholder="请确认新密码" class="flex" placeholder-class="pla"/>
			<text class="iconfont" :class="seerepwd?'icon-yanjing':'icon-yanjing1'" @click="seerepwd = !seerepwd"></text>
		</view>
		<view class="btn" @click="submit">修改</view>
	</view>
</template>

<script>
	var that;
	export default {
		data() {
			return {
				oldpwd:'',
				seeoldpwd: false,
				newpwd:'',
				seenewpwd: false,
				repwd:'',
				seerepwd: false
			};
		},
		onLoad() {
			that = this
			// #ifdef H5
			this.$common.H5HideShare()
			// #endif
		},
		methods:{
			submit(){
				if(!that.oldpwd.trim()){
					uni.showToast({title:'请输入旧密码',icon:'none'})
					return
				}
				if(!that.newpwd.trim()){
					uni.showToast({title:'请输入新密码',icon:'none'})
					return
				}
				if(!that.repwd.trim()){
					uni.showToast({title:'请确认新密码',icon:'none'})
					return
				}
				if(that.repwd != that.newpwd){
					uni.showToast({title:'新密码输入不一致',icon:'none'})
					return
				}
				that.$http.post({
					url: '/singleSaleManageApi/modify_upass',
					data:{
						shop_id: uni.getStorageSync('store_id'),
						upass: that.oldpwd,
						newpass: that.newpwd
					}
				}).then(res => {
					uni.showToast({
						title: res.msg,
						icon:'none'
					})
					if (res.code == 200) {
						setTimeout(()=>{
							uni.navigateBack({
								delta:1
							})
						},1500)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page{
		background-color: #FFFFFF;
		padding: 24rpx $page-space;
		.item{
			height: 98rpx;
			border: 1px solid #EEEEEE;
			border-radius: $border-radius-base;
			padding: 0 20rpx 0 28rpx;
			margin-bottom: 24rpx;
			.iconfont{
				font-size: 38rpx;
				color: #aaaaaa;
			}
			.active{
				color: $uni-color-primary;
			}
			input{
				outline: none;
				border: none;
				background: none;
			}
		}
		.tips{
			color: #FF432A;
			padding: 0 20rpx;
		}
		.btn{
			margin-top: 98rpx;
			border-radius: $border-radius-base;
			color: white;
			text-align: center;
			line-height: 88rpx;
			font-size: $font-size-lg;
			background: #FF784A linear-gradient(157deg, rgba(255, 255, 255, 0.37) 0%, rgba(255, 255, 255, 0) 100%);
		}
	}
</style>
